<?php
namespace org\crawlgenie\application\database;
use org\crawlgenie\application\registry\Registry;
use \CGException;
use \CGConfig;

/**
 * Wrapper class for the core and specialised connector DB classes
 * Implemented using a classic singleton design pattern
 *
 *  @author $Author$:
 *  $Date$:
 *  $Id$:
 *  @version $Rev$:
 *  @package crawlgenie.application
 *  @subpackage database
 */


final class Database {

    private static $dbConnObject;

    private function __construct() {
        $dsn = CGConfig::$dbType . ':dbname=' . CGConfig::$dbName . ';host=' . CGConfig::$dbHost;
        self::$dbConnObject = new DatabasePDO($dsn, CGConfig::$dbUserName, CGConfig::$dbPassword);
    }


    public static function getConnection() {
        if (!isset(self::$dbConnObject)) {
            $c = __CLASS__;
            $createNew = new $c;
        }
        return self::$dbConnObject;
    }

}


?>